package im.yisme.view.ui.util;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;

public class BitmapAlpha {

	public static Bitmap setAlpha(Bitmap sourceImg, int number) {
        int[] argb = new int[sourceImg.getWidth() * sourceImg.getHeight()];
        sourceImg.getPixels(argb, 0, sourceImg.getWidth(), 0, 0, sourceImg
                        .getWidth(), sourceImg.getHeight());// 获得图片的ARGB值
        number = number * 255 / 100;
        for (int i = 0; i < argb.length; i++) {
        	if((argb[i] | 0x00000000) != 0)
                argb[i] = (number << 24) | (argb[i] & 0x00FFFFFF);
        }
        sourceImg = Bitmap.createBitmap(argb, sourceImg.getWidth(), sourceImg
                        .getHeight(), Config.ARGB_8888);

        return sourceImg;
	}
}
